/*
  Copyright 1996-2003
  Simon Whiteside

*/
package simkin.examples.inherits;
import simkin.*;
import java.io.FileInputStream;

/**
 * This Java program loads XML files containing Simkin script.
 *<p>The program calls the "main" method on each script it loads.
 *<p>The script names are passed on the command line.
*/
public class Inherits {
    /**
     * Entry point for the Inherits application. It expects to have an argument giving the filename of an XML file to be loaded.
     * <p>An {@link InheritsExecutable InheritsExecutable} object is created, passed the file, and then the method "main" is called
     */
    static public void main(String[] args){
	if (args.length>0){
	    for (int i=0;i<args.length;i++){
		try{
		    // Create an interpreter and a context
		    Interpreter interp=new Interpreter();
		    ExecutableContext ctxt=new ExecutableContext(interp);

		    // create an XML Executable
		    InheritsExecutable executable=new InheritsExecutable(args[i],new FileInputStream(args[i]));

		    // and call the "main" method
		    executable.method("main",null,ctxt);
		}catch(Exception e){
		    e.printStackTrace();
		}
	    }
	}else{
	    System.out.println("Syntax: java simkin.examples.Inherits <xml file>");
	}
    }
}
